/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cp3120.model.pricing;

import cp3120.model.*;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author jc154639
 */
public abstract class PricingStrategy {
    private int id;
    private String name;
    private Map<String, String> vars = new HashMap<String, String>();

    public abstract void execute(Purchase purchase);

    public synchronized Map<String, String> getVars() {
        return new HashMap<String, String>(vars);
    }

    public synchronized void setVars(Map<String, String> vars) {
        this.vars = vars;
    }

    public synchronized String getVar(String var) {
        return vars.get(var);
    }

    public synchronized void setVar(String var, String value) {
        if (vars.containsKey(var)) {
            vars.remove(var);
        }
        vars.put(var, value);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String toString() {
        return getName() == null ? getClass().getSimpleName() : getName();
    }
}
